//School of Informatics Xiamen University, GPL-3.0 license
package cn.edu.xmu.oomall.product.mapper.openfeign;

import cn.edu.xmu.javaee.core.model.InternalReturnObject;
import cn.edu.xmu.oomall.product.mapper.openfeign.po.Shop;
import cn.edu.xmu.oomall.product.mapper.openfeign.po.Template;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.edu.xmu.oomall.product.mapper.openfeign.po.Consignee;

@FeignClient("shop-service")
public interface ShopMapper {

//    @GetMapping("/shops/{id}")
//    InternalReturnObject<Shop> getShopById(@PathVariable Long id);
//
//    @GetMapping("/shops/{shopId}/templates/{id}")
//    InternalReturnObject<Template> getTemplateById(@PathVariable Long shopId, @PathVariable Long id);
    default InternalReturnObject<Shop> getShopById(Long id) {
        // 创建虚拟商铺数据
        Shop shop = new Shop();
        shop.setId(id);
        shop.setName("虚拟商铺");
        shop.setStatus((byte) 1);

        Consignee consignee = new Consignee();
        consignee.setName("虚拟收货人");
        consignee.setMobile("12345678901");
        consignee.setRegionId(100L);
        consignee.setAddress("虚拟地址");
        shop.setConsignee(consignee);

        shop.setDeposit(1000L);
        shop.setDepositThreshold(500L);

        return new InternalReturnObject<>(shop);
    }

    default InternalReturnObject<Template> getTemplateById(Long shopId, Long id) {
        // 创建虚拟模板对象
        Template template = new Template();
        template.setId(id); // 使用传入的模板 id
        template.setName("虚拟模板"); // 虚拟模板名称
        return new InternalReturnObject<>(template);
    }
}
